IdeaBlade.Validation Assembly > IdeaBlade.Validation Namespace : DelegateVerifier<T> Class |
'Declaration
Public Class DelegateVerifier(Of T As Class) Inherits Verifier(Of T) Implements System.IComparable(Of Verifier)
'Usage
Dim instance As DelegateVerifier(Of T)
public class DelegateVerifier<T> : Verifier<T>, System.IComparable<Verifier> where T: class
private DelegateVerifier SampleDelegateVerifier() { // A simple example adding a delegate verifier to ensure that Employee // BirthDate falls before HireDate. // Apply verifier only when have data for both properties. ApplicabilityConstraint<Employee> constraint = (emp, trigger, context) => { return emp.HireDate.HasValue && emp.BirthDate.HasValue ? VerifierApplicability.Yes : VerifierApplicability.InsufficientData; }; // Define the verification performed - BirthDate must precede HireDate VerifierCondition<Employee> condition = (emp, trigger, context) => { return new VerifierResult(emp.BirthDate < emp.HireDate); }; var errorMessage = "Must be born before hired"; // Create the verifier. Execute only after set and on instance. var v = new DelegateVerifier<Employee>(errorMessage, constraint, condition); v.VerifierOptions.ExecutionModes = VerifierExecutionModes.InstanceAndOnAfterSetTriggers; // Add triggers - setters for HireDate and BirthDate properties will trigger. v.AddTriggers(Employee.PropertyMetadata.HireDate.Name, Employee.PropertyMetadata.BirthDate.Name); return v; }
System.Object
IdeaBlade.Validation.Verifier
IdeaBlade.Validation.Verifier<T>
IdeaBlade.Validation.DelegateVerifier<T>
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2